package news

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model"
	"parking-lot-go-admin/model/dingtalk"

	"github.com/gin-gonic/gin"
)

func DeleteNews(c *gin.Context) {
	requestDataStruct := struct {
		Id int `json:"id"`
	}{}

	c.ShouldBindJSON(&requestDataStruct)

	var dingtalkNewsStruct dingtalk.DingtalkNewsStruct
	if err := model.DeleteModelData(
		model.Db,
		dingtalkNewsStruct.TableName(),
		map[string]interface{}{
			"id": requestDataStruct.Id,
		},
		&dingtalkNewsStruct,
	); err != nil {
		controller.Fail(c, err.Error())
		return
	}

	controller.Success(c, "")
}
